/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package demo;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;
import javax.ejb.Stateless;

/**
 *
 * @author QUANG2PRO
 */
@Stateless
public class ExampleBean implements ExampleBeanRemote {

    @Override
    public String GetPassword(String userName) {

        String empName = null;
        try {

            Connection con = helper.ConnectionHelper.GetConnection();
            String sql = "SELECT Password FROM Users WHERE UserName = ?";
            PreparedStatement p = con.prepareStatement(sql);
            p.setString(1, userName);
            ResultSet rs = p.executeQuery();

            if (rs.next()) {
                empName = rs.getString("Password");
            }

        } catch (SQLException e) {
            System.out.println("SQL Exception: " + e.toString());
        }
        return empName;
    }

    

}
